package org.jiuling.network.tools.http.request.factory;

import org.jiuling.local.tools.exception.LocalToolsException;
import org.jiuling.network.tools.http.request.enums.RequestMethodEnum;
import org.jiuling.network.tools.http.request.enums.SSLProtocol;
import org.jiuling.network.tools.http.request.exception.RequestException;
import org.jiuling.network.tools.http.request.model.HttpRequestBody;
import org.jiuling.network.tools.http.request.model.HttpRequestHeader;
import org.jiuling.network.tools.http.request.model.HttpRequestParam;
import org.jiuling.network.tools.http.request.model.HttpResponse;

import javax.net.ssl.X509TrustManager;
import java.io.IOException;
import java.net.Proxy;
import java.security.KeyManagementException;
import java.security.NoSuchAlgorithmException;

/**
 * HTTP请求工厂接口
 * @author 紫灵
 * @date 2022年11月21日 23时06分32秒
 */
public interface HttpRequestFactory {
    
    HttpRequestFactory setRequestMethod(RequestMethodEnum requestMethod);

    /**
     * 设置请求参数
     * @param httpRequestParam 请求参数
     * @return http请求接口
     */
    HttpRequestFactory setRequestParam(HttpRequestParam httpRequestParam);

    /**
     * 设置请求头
     * @param httpRequestHeader 请求头
     * @return http请求接口
     */
    HttpRequestFactory setRequestHeader(HttpRequestHeader httpRequestHeader);

    /**
     * 添加请求内容
     * @param httpRequestBody 请求内容
     * @return http请求接口
     */
    HttpRequestFactory setRequestBody(HttpRequestBody httpRequestBody);

    /**
     * 设置连接超时时间
     * @param connectTimeout 连接超时时间 默认3000毫秒
     * @return http请求接口
     */
    HttpRequestFactory setConnectTimeout(Integer connectTimeout);


    /**
     * 设置读取超时时间
     * @param readTimeout 读取超时时间 默认5000毫秒
     * @return http请求接口
     */
    HttpRequestFactory setReadTimeout(Integer readTimeout);

    /**
     *  设置代理
     * @param proxy 代理
     * @return http请求接口
     */
    HttpRequestFactory setProxy(Proxy proxy);

    /**
     * 设置信任管理器
     * @param x509TrustManager 信任管理器
     * @return http请求接口
     */
    HttpRequestFactory setX509TrustManager(X509TrustManager x509TrustManager);

    /**
     * 设置SSL协议
     * @param sslProtocol SSL协议
     * @return http请求接口
     */
    HttpRequestFactory setSslProtocol(SSLProtocol sslProtocol);

    /**
     * 发送请求
     * @param path 请求地址
     * @return 请求相应
     */
    HttpResponse send(String path) throws IOException, RequestException, LocalToolsException, NoSuchAlgorithmException, KeyManagementException;


}
